package com.lsq.lwf.common.aspect.factory;

import com.lsq.lwf.common.aspect.LightHandler;
import com.lsq.lwf.common.exception.LightException;

public class LightAspectFactory {

	@SuppressWarnings("rawtypes")
	private static Object getInstance(String className) {

		Object obj = null;

		try {
			Class c = Class.forName(className);

			obj = c.newInstance();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}

		return obj;
	}
	
	public static Object getProxyObject(String className){
		Object proxy=null;
		LightHandler handler=new LightHandler();
		Object obj=getInstance(className);
		
		if(obj!=null){
			proxy=handler.bind(obj);
		}else{
			new LightException(className+" is not found!");
		}
		
		return proxy;
	}
}
